local sk__sijian = fk.CreateSkill {

  name = "sk__sijian",

  tags = {  },

}



sk__sijian:addEffect(fk.AfterCardsMove, {
  name = "sk__sijian",
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(sk__sijian.name) and player:isKongcheng() then
      local yes = false
      for _, move in ipairs(data) do
        if move.from == player then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand then
              yes = true
              break
            end
          end
        end
      end
      if yes then
        return player.hp > 0 and table.find(player.room:getOtherPlayers(player), function(p) return not p:isNude() end)
      end
    end
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local targets = table.map(table.filter(room:getOtherPlayers(player),
      function(p) return not p:isNude()
    end), Util.IdMapper)
    local to = room:askForChoosePlayers(player, targets, 1, 1, "#sk__sijian-choose:::"..player.hp, sk__sijian.name, true)
    if #to > 0 then
      event:setCostData(self, to[1])
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local to = room:getPlayerById(event:getCostData(self))
    local cards = room:askForCardsChosen(player, to, 1, player.hp, "he", sk__sijian.name, "#sk__sijian-discard::"..to.id..":"..player.hp)
    room:throwCard(cards, sk__sijian.name, to, player)
  end,
})

return sk__sijian